{template 'header'}
<link rel="stylesheet" href="../addons/mx_shop/resources/cgc/css/user/login.css">

<body>

<div class="log_wrap">
    <div class="header">
        <div class="logo"><img src="../addons/mx_shop/resources/cgc/images/logo.png" alt=""></div>
        <p class="tit">用户登录</p>
        <div class="xian"><img src="../addons/mx_shop/resources/cgc/images/xian.png" alt=""></div>
    </div>


    <div class="content">
        <div class="inputwrap">
            <div class="mui-input-row">
                <i class="iconfont icon-shouji"></i>
                <input type="text" placeholder="输入手机号" id="phonum">
            </div>
            <div class="mui-input-row">
                <i class="iconfont icon-suo"></i>
                <input type="password" placeholder="输入密码" id="pass">
                <span class="iconfont icon-yanjing"></span>
            </div>
            <p class="fogotpass"><a href="{php echo mobileUrl('user/change')}" style="color: #6a96f3">忘记密码</a></p>
        </div>

        <div class="login" @click="login();">登录</div>
        <a href="{php echo mobileUrl('user/reg')}"><div class="res">新用户注册</div></a>

        <!--<div class="login_three">
            <p>第三方登录</p>
            <div class="xian"></div>
        </div>-->

        <!--<div class="qq">
            &lt;!&ndash;<span class="iconfont icon-weixin"></span>
            <span class="iconfont icon-qq" style="margin-left: .3rem;"></span>&ndash;&gt;
            <span><img src="../addons/mx_shop/resources/cgc/images/weixin.png" alt=""></span>
            <span><img src="../addons/mx_shop/resources/cgc/images/qq.png" alt=""></span>

        </div>-->
        <input type="hidden" value="{$token}" id="token">
    </div>
</div>
<script>

    var vm=new Vue({
        el:'.log_wrap',
        data:{

        },
        methods:{
            login:function(){
                var phonum=$("#phonum").val(),
                     pass=$("#pass").val(),
                     token=$("#token").val();

                if(phonum==""){
                    $.show("请输入手机号");return;
                }

                if(!mainApp.isPhone(phonum)){
                    $.show("手机号格式不正确");return;
                }

                if(pass==""){
                    $.show("请输入密码");return;
                }

                if(pass.length<6 || pass.length>20){
                    $.show("请输入6-20位的密码");return;
                }

                this.$http({
                    method:"POST",
                    url:mainApp.getUrl('user/login'),
                    params:{phone:phonum,pwd:pass,token:token}
                }).then(function(msg){
                    if(msg.data.status==1){
                        $.succeed("登录成功");

                        setTimeout(function(){
                            var backurl = '{$backurl}' || mainApp.getUrl('');
                            window.location.href=backurl;
                        },1000);

                    }else{
                        $.show(msg.data.result.message);
                    }
                });

            }
        }
    });
</script>
</body>
</html>